<script setup lang="ts">
import type { VxeGridProps } from '#/adapter/vxe-table';

import { Page } from '@vben/common-ui';
import { storeToRefs } from '@vben/stores';

import { useVbenVxeGrid } from '#/adapter/vxe-table';
import { useMqttStore } from '#/store/mqtt';

const useMqtt = useMqttStore();
const { mqttTable } = storeToRefs(useMqtt);

const gridOptions: VxeGridProps = {
  keepSource: true,
  toolbarConfig: {
    custom: false,
    refresh: false,
    zoom: false,
  },
  columns: [
    {
      title: '序号',
      type: 'seq',
      width: 60,
    },
    {
      title: '更新时间',
      field: 'time',
    },
    {
      title: '类型',
      field: 'type',
    },
    {
      title: '消息内容',
      field: 'content',
    },
  ],
  data: mqttTable.value,
  rowConfig: {
    keyField: 'id',
  },
  pagerConfig: {
    enabled: false,
  },
  id: 'iot-simulatorLog-index',
};

const [BasicTable] = useVbenVxeGrid({
  gridOptions,
});
</script>

<template>
  <Page>
    <BasicTable />
  </Page>
</template>
